From c5aea946fd48b2176b7e65bf92a3c0ff951678cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 16 Apr 2026 04:33:45 +0200 Subject: [PATCH] appFavorites: Only emit :changed signal on changes We were emitting the :changed signal on every setting or app-filter change even though the actual favorites list might not have changed. So now every time it's relevant, check if something is changed before emitting the :changed signal. We do a deep check of the app IDs as potentially an app could have been removed while another is being installed during the same update window, and the length of the IDs list wouldn't change. Part-of: --- js/ui/appFavorites.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index b4dec3aac..a4ec6cb30 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -9,20 +9,32 @@ class AppFavorites extends Signals.EventEmitter { // Filter the apps through the user’s parental controls. this._parentalControlsManager = ParentalControlsManager.getDefault(); - this._parentalControlsManager.connect('app-filter-changed', () => { - this.reload(); - this.emit('changed'); - }); + this._parentalControlsManager.connect('app-filter-changed', + () => this._updateFavorites()); this.FAVORITE_APPS_KEY = 'favorite-apps'; this._favorites = {}; - global.settings.connect(`changed::${this.FAVORITE_APPS_KEY}`, this._onFavsChanged.bind(this)); + global.settings.connect(`changed::${this.FAVORITE_APPS_KEY}`, + () => this._updateFavorites()); + this.reload(); } - _onFavsChanged() { + _updateFavorites() { + const oldIDs = this._getIds(); this.reload(); - this.emit('changed'); + const newIDs = this._getIds(); + + const haveChanged = () => { + if (oldIDs.length !== newIDs.length) + return true; + + return oldIDs.some( + (id, i) => id !== newIDs[i] || !this.isFavorite(id)); + }; + + if (haveChanged()) + this.emit('changed'); } reload() { -- 2.39.5